package com.zengqingfa.examples.mybatisplus.strategy;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 *
 * @fileName: ProcessStrategyContext
 * @author: zengqf3
 * @date: 2021-4-8 16:29
 * @description: 流程实例上下文
 */
@Component
public class ProcessStrategyContext {

    @Autowired
    ProcessStrategyFactory processStrategyFactory;

    public String process(Long processId) {
        ProcessStrategy processStrategy = processStrategyFactory.getByProcessId(processId);
        if (processStrategy == null) {
            throw new IllegalArgumentException("流程类型没有对应的策略,processId=" + processId);
        }
        return processStrategy.callBack(processId);
    }
}
